<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:61:"F:\yxl\tp5.com\public/../application/admin\view\auth\add.html";i:1562592134;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body class="layui-layout-body">

<div class="layui-header">

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">管理员昵称</label>
            <div class="layui-input-block">
                <input type="text" name="user_name" lay-verify="title" autocomplete="off" placeholder="请输入昵称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">所属用户组</label>
            <div class="layui-input-block">
                <?php foreach($groups as $g): ?>
                <input type="checkbox" name="group[<?php echo $g['id']; ?>]" title="<?php echo $g['title']; ?>">
                <?php endforeach; ?>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="demo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>

    <div class="layui-footer">

    </div>

    <script src="/static/layui/layui.js"></script>

    <script>
        layui.use(['form', 'layedit', 'laydate','jquery','upload'], function(){
            var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate
                ,jquery = layui.jquery

            //自定义验证规则
            form.verify({
                pass: [
                    /^[\S]{6,12}$/
                    ,'密码必须6到12位，且不能出现空格'
                ]
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });

            //监听提交
            form.on('submit(demo)',function(data){
                jquery.post("/admin/auth/add_do",data.field,function(res){
                    if(res.code == 1){
                        layer.msg('添加成功',{icon:1,time:1000},function(){
                            window.parent.location.reload();
                        });
                    }else{
                        layer.msg('添加失败');
                    }
                });
                return false;
            });
        });
    </script>

</div>

</body>
</html>